Skip Headers

Oracle® Objects for OLE C++ Class Library Developer's Guide 10g Release 2 (10.2) Part Number B14308-01 |
Home | Book List | Contents | Index | Master Index | Feedback

# GetEditMode Method

Applies To

ODynaset

Description

This method returns the edit mode of the current record.

Usage

int GetEditMode(void) const

Remarks

The edit mode of the current record can be one of the following forms:

ODYNASET_EDIT_NOEDIT // the current record is not being edited

ODYNASET_EDIT_EDITING // the current record is being edited

ODYNASET_EDIT_NEWRECORD // the current record was added, either with AddNewRecord or DuplicateRecord

If there is no current record, or the ODynaset is not open, or there is some other error, ODYNASET_EDIT_NOEDIT is returned.

Return Value

One of the ODYNASET_EDIT_* defines; ODYNASET_EDIT_NOEDIT on error.

Example This example shows how each of the different edit modes can occur.

    // construct and open an ODatabase
    ODatabase odb("ExampleDB", "scott", "tiger");

    // construct an ODynaset but don't open it
    ODynaset dyn;

    int editmode;
    editmode = dyn.GetEditMode();
    // editmode is ODYNASET_EDIT_NOEDIT because the dynaset is not open

    // now open the dynaset
    dyn.Open(odb, "select * from emp");
    dyn.MoveFirst();

    // What is the edit mode when we're just looking at data?
    editmode = dyn.GetEditMode();
    // editmode is ODYNASET_EDIT_NOEDIT because the current record has
    //    not been changed or added

    // What's the edit mode when we're editing?
    dyn.StartEdit();  // start editing
    editmode = dyn.GetEditMode();
    // now editmode is ODYNASET_EDIT_EDITING
    dyn.SetFieldValue("sal", 8000);  // set some data
    dyn.Update();
    // the edit mode is back to ODYNASET_EDIT_NOEDIT after the Update

    // now add a record
    dyn.AddNewRecord();
    editmode = dyn.GetEditMode();
    // now editmode is ODYNASET_EDIT_NEWRECORD
    dyn.Update();  // save the new record
    // edit mode is back to ODYNASET_EDIT_NOEDIT again
    /*
    By the way, dyn.ErrorNumber() would now report an error because the
    update didn't occur. That's because the emp table requires some
    fields to have non-NULL values and we didn't set them.
    */